package cn.gson.springboot.model.pjos;

import javax.persistence.*;
import java.math.BigDecimal;
import java.sql.Date;
import java.sql.Timestamp;
import java.util.Collection;
import java.util.List;
import java.util.Objects;

@Entity
public class Contract {
    private int contractId;//id
    private String contractName;//合同名称
    private String contractTheme;//主题
    private Date effectTime;//生效时间
    private Date failureTime;//失效时间
    private String customerName;//客户签约人
    private Emp empId8;//员工信息
    private Timestamp signingTime;//签约时间
    private BigDecimal totalAmount;//总金额
    private BigDecimal receivableAmount;//回款金额
    private TermsPayment termsPayment;//付款方式
    private Integer contractState;//状态
    private String noteInfo;//备注
    private Customer customerByCustomId;//客户信息
    private BusinessInfo businessInfoByBusinesId;//商机信息
    private Offer offerByOfferId2;//报价单信息
    private List<OfferContractinfo> offerContractinfosByContractId;//无用
    private List<OrderInfo> orderInfosByContractId;//订单信息

    private Integer contractApproverid;//审批人id  contract_approverid
    private Integer contractAppstate;//审批状态 contract_appstate
    
    @Basic
    @Column(name = "contract_approverid")
    public Integer getContractApproverid() {
        return contractApproverid;
    }

    public void setContractApproverid(Integer contractApproverid) {
        this.contractApproverid = contractApproverid;
    }

    @Basic
    @Column(name = "contract_appstate")
    public Integer getContractAppstate() {
        return contractAppstate;
    }

    public void setContractAppstate(Integer contractAppstate) {
        this.contractAppstate = contractAppstate;
    }

    @Id
    @Column(name = "contract_id")
    public int getContractId() {
        return contractId;
    }

    public void setContractId(int contractId) {
        this.contractId = contractId;
    }

    @Basic
    @Column(name = "contract_name")
    public String getContractName() {
        return contractName;
    }

    public void setContractName(String contractName) {
        this.contractName = contractName;
    }

    @Basic
    @Column(name = "contract_theme")
    public String getContractTheme() {
        return contractTheme;
    }

    public void setContractTheme(String contractTheme) {
        this.contractTheme = contractTheme;
    }

    @Basic
    @Column(name = "effect_time")
    public Date getEffectTime() {
        return effectTime;
    }

    public void setEffectTime(Date effectTime) {
        this.effectTime = effectTime;
    }

    @Basic
    @Column(name = "failure_time")
    public Date getFailureTime() {
        return failureTime;
    }

    public void setFailureTime(Date failureTime) {
        this.failureTime = failureTime;
    }

    @Basic
    @Column(name = "customer_name")
    public String getCustomerName() {
        return customerName;
    }

    public void setCustomerName(String customerName) {
        this.customerName = customerName;
    }

    @ManyToOne
    @JoinColumn(name = "emp_id8", referencedColumnName = "employees_id")
    public Emp getEmpId8() {
        return empId8;
    }

    public void setEmpId8(Emp empId8) {
        this.empId8 = empId8;
    }

    @Basic
    @Column(name = "signing_time")
    public Timestamp getSigningTime() {
        return signingTime;
    }

    public void setSigningTime(Timestamp signingTime) {
        this.signingTime = signingTime;
    }

    @Basic
    @Column(name = "total_amount")
    public BigDecimal getTotalAmount() {
        return totalAmount;
    }

    public void setTotalAmount(BigDecimal totalAmount) {
        this.totalAmount = totalAmount;
    }

    @Basic
    @Column(name = "receivable_amount")
    public BigDecimal getReceivableAmount() {
        return receivableAmount;
    }

    public void setReceivableAmount(BigDecimal receivableAmount) {
        this.receivableAmount = receivableAmount;
    }

    @Basic
    @Column(name = "contract_state")
    public Integer getContractState() {
        return contractState;
    }

    public void setContractState(Integer contractState) {
        this.contractState = contractState;
    }

    @Basic
    @Column(name = "note_info")
    public String getNoteInfo() {
        return noteInfo;
    }

    public void setNoteInfo(String noteInfo) {
        this.noteInfo = noteInfo;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Contract contract = (Contract) o;
        return contractId == contract.contractId &&
                Objects.equals(contractName, contract.contractName) &&
                Objects.equals(contractTheme, contract.contractTheme) &&
                Objects.equals(effectTime, contract.effectTime) &&
                Objects.equals(failureTime, contract.failureTime) &&
                Objects.equals(customerName, contract.customerName) &&
                Objects.equals(empId8, contract.empId8) &&
                Objects.equals(signingTime, contract.signingTime) &&
                Objects.equals(totalAmount, contract.totalAmount) &&
                Objects.equals(receivableAmount, contract.receivableAmount) &&
                Objects.equals(termsPayment, contract.termsPayment) &&
                Objects.equals(contractState, contract.contractState) &&
                Objects.equals(noteInfo, contract.noteInfo);
    }

    @Override
    public int hashCode() {
        return Objects.hash(contractId, contractName, contractTheme, effectTime, failureTime, customerName, empId8, signingTime, totalAmount, receivableAmount, termsPayment, contractState, noteInfo);
    }

    @ManyToOne
    @JoinColumn(name = "custom_id", referencedColumnName = "custom_id")
    public Customer getCustomerByCustomId() {
        return customerByCustomId;
    }

    public void setCustomerByCustomId(Customer customerByCustomId) {
        this.customerByCustomId = customerByCustomId;
    }

    @ManyToOne
    @JoinColumn(name = "busines_id", referencedColumnName = "busines_id")
    public BusinessInfo getBusinessInfoByBusinesId() {
        return businessInfoByBusinesId;
    }

    public void setBusinessInfoByBusinesId(BusinessInfo businessInfoByBusinesId) {
        this.businessInfoByBusinesId = businessInfoByBusinesId;
    }

    @ManyToOne
    @JoinColumn(name = "offer_id2", referencedColumnName = "offer_id2")
    public Offer getOfferByOfferId2() {
        return offerByOfferId2;
    }

    public void setOfferByOfferId2(Offer offerByOfferId2) {
        this.offerByOfferId2 = offerByOfferId2;
    }

    @OneToMany(mappedBy = "contractByContractId")
    public List<OfferContractinfo> getOfferContractinfosByContractId() {
        return offerContractinfosByContractId;
    }

    public void setOfferContractinfosByContractId(List<OfferContractinfo> offerContractinfosByContractId) {
        this.offerContractinfosByContractId = offerContractinfosByContractId;
    }

    @OneToMany(mappedBy = "contractByContractId")
    public List<OrderInfo> getOrderInfosByContractId() {
        return orderInfosByContractId;
    }

    public void setOrderInfosByContractId(List<OrderInfo> orderInfosByContractId) {
        this.orderInfosByContractId = orderInfosByContractId;
    }

    @ManyToOne
    @JoinColumn(name = "terms_payment")
    public TermsPayment getTermsPayment() {
        return termsPayment;
    }

    public void setTermsPayment(TermsPayment termsPayment) {
        this.termsPayment = termsPayment;
    }

    /*@Override
    public String toString() {
        return "Contract{" +
                "contractId=" + contractId +
                ", contractName='" + contractName + '\'' +
                ", contractTheme='" + contractTheme + '\'' +
                ", effectTime=" + effectTime +
                ", failureTime=" + failureTime +
                ", customerName=" + customerName +
                ", empId8=" + empId8 +
                ", signingTime=" + signingTime +
                ", totalAmount=" + totalAmount +
                ", receivableAmount=" + receivableAmount +
                ", termsPayment=" + termsPayment +
                ", contractState=" + contractState +
                ", noteInfo='" + noteInfo + '\'' +
                ", customerByCustomId=" + customerByCustomId +
                ", businessInfoByBusinesId=" + businessInfoByBusinesId +
                ", offerByOfferId2=" + offerByOfferId2 +
                ", offerContractinfosByContractId=" + offerContractinfosByContractId +
                ", orderInfosByContractId=" + orderInfosByContractId +
                '}';
    }*/
}
